package gui;

import java.awt.event.ActionEvent;
import java.util.Observable;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JOptionPane;

/**
 * Do not use this one use
 * GuiController.getSaveButton() instead.
 * @author Danny
 *
 */
@SuppressWarnings("serial")
public class SaveControl extends Observable{
	JButton myButton;
	String[] myOptions = {"Save Current Changes", 
			"Do Not Save Changes"};
	public SaveControl() {
		myButton = new JButton( 
		new AbstractAction("Save") {
			@Override
			public void actionPerformed(ActionEvent e) {
				int selection =
					JOptionPane.showOptionDialog(null, 
							"Save Current Changes?", 
							"Save", 
							JOptionPane.OK_CANCEL_OPTION, 
							JOptionPane.QUESTION_MESSAGE, 
							null, 
							myOptions, 
							0);
				switch (selection) {
				case 0:
					setChanged();
					notifyObservers(State.SAVE);
					break;
				default:
					// do nothing
					break;
				}
			}
		});
	}
	public JButton getButton() {
		return myButton;
	}
}
